package com.jdk8datedemo;

import java.time.Duration;
import java.time.LocalDateTime;

public class DurationDemo {
    public static void main(String[] args) {
        //当前本地年月日
        LocalDateTime now = LocalDateTime.now();
        System.out.println(now);

        //生日的年月日
        LocalDateTime birthday = LocalDateTime.of(2000, 1, 1,0,00,00,00);
        System.out.println(birthday);

        //第二个参数减第一个参数
        Duration duration = Duration.between(birthday, now);
        System.out.println(duration);
        System.out.println(duration.toDays());
        System.out.println(duration.toHours());
        System.out.println(duration.toMillis());
        System.out.println(duration.toNanos());
    }
}
